package com.open.capacity.controller;

import com.open.capacity.common.web.Result;
import com.open.capacity.model.BusinessData;
import com.open.capacity.service.BusinessDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@RequestMapping("/business/data")
public class BusinessDataController {
    @Autowired
    private BusinessDataService businessDataService;


    /**
     *修改商家个人数据
     * @param businessData
     * @return
     */
    @PostMapping("/update")
    public Object update(BusinessData businessData) {
        businessDataService.update(businessData);
        return Result.succeed("商家个人信息修改成功！");
    }/**
     *修改商家个人数据
     * @param businessData
     * @return
     */
    @PostMapping("/updateHead")
    public Object updateHead(BusinessData businessData) {
        businessDataService.updateHead(businessData);
        return Result.succeed("商家个人touxiang信息修改成功！");
    }
/**
     *修改商家个人密码
     * @param passwd
     * @return
     */
    @PostMapping("/updatePassword")
    public Object updatePassword(String passwd,Long busiid) {
        businessDataService.updatePassword(passwd,busiid);
        return Result.succeed("商家个人密码修改成功！");
    }

    /**
     * 显示商家个人信息 通过ID
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Result findById(Long id) {
        BusinessData list = businessDataService.findById(id);
        return Result.succeed(list,"商家个人信息显示成功！");
    }


//    @PostMapping("/add")
//    public CommonResult add(BusinessData businessData) {
//        businessDataService.add(businessData);
//        return CommonResult.success(null);
//    }
//
//    @PostMapping("/delete")
//    public CommonResult delete(Long id) {
//        businessDataService.delete(id);
//        return CommonResult.success(null);
//    }
//
//    @GetMapping("/findAll")
//    public CommonResult findAll(PageModel pageModel) {
//        PageInfo<BusinessData> list = businessDataService.findAll(pageModel);
//        HashMap<String, PageInfo<BusinessData>> map = new HashMap<>();
//        map.put("data", list);
//        return CommonResult.success(map);
//    }
}
